﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Timers;
using MonitorServer;

namespace Wicresoft.WinService
{
    public partial class Service : ServiceBase
    {
        Timer timer;
        object mylock = new object();
        public Service()
        {
            InitializeComponent();
        }
        void TimerInit()
        {
            timer = new Timer(10);
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();
        }
        void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            lock (mylock)
            {
                MessageQueueService service = MessageQueueService.CrateInstance();
                service.RequestSave();
                //service.ActionSave();
                //string result = 
                //if (!string.IsNullOrEmpty(result))
                    
                //    Console.WriteLine(result);
            }
            System.Threading.Thread.Sleep(1000);
        }
        protected override void OnStart(string[] args)
        {
            TimerInit();
            Host.StartService();
        }

        protected override void OnStop()
        {
            Host.StopService();
        }
    }
}
